Technical Field
The present application relates to two-dimensional codes, and in particular, to a decoding method for a matrix two-dimensional code.
Related Art
People read traditional books, newspapers, and so on mainly with eyes. Such an information acquisition manner is relatively boring, and reading for a long time causes eyestrain easily. Moreover, people who are blind or have eye disease cannot read such traditional publications. Therefore, voice reading publications appear in recent years. For example, in the China invention patent of Patent Application No. ZL200610156879.4, for a multimedia print reader (MPR) publication, content in a voice reading publication can be decoded by using a two-dimensional code voice reading apparatus, so that a reader can listen to video content while reading the publication, thereby improving the reading or memorizing efficiency, and making it easier for children or people having eye or ear disease to learn. For MPR two-dimensional codes, refer to the MPR publication industry standard, including part 1 (Symbology Specifications for MPR Code, Standard No. CY/T 58.1-2009), part 2 (Encoding Rules for MPR Code, Standard No.: CY/T 58.2-2009), part 3 (General Production Specifications, Standard No.: CY/T 58.3-2009), part 4 (Printing Quality Requirement and Test Method for MPR Code, Standard No.: CY/T 58.4-2009) and part 5 (Basic Management Specifications, Standard No.: CY/T 58.5-2009) for MPR publications.
A code pattern array is printed in the voice reading publication in the foregoing China invention patent. Code pattern symbols in the code pattern array are rectangular, bar code cells in the code pattern symbol are solid points arranged at equal intervals, and cells located at four corners of the code pattern symbol are positioning points to define and recognize the border. The rest cells are data points, and the area of the positioning point is larger than the area of the data point. The code pattern symbol is arranged repeatedly on a basement and seamlessly jointed as a code pattern array. The code pattern array at least includes two same code pattern symbols, and adjacent code pattern symbols share a same positioning point; the data point cells are all included in a rectangular frame formed by connecting the centers of the adjacent positioning point cells. A decoding method thereof includes: first selecting positioning points; then performing rectangle matching on positioning point cells; after a single code pattern symbol is selected, performing data point grouping to reconstruct a data point matrix. Specifically, the decoding method includes the following steps:
1) reading a code pattern by using a reading device to obtain a gray code pattern image; 2) performing binary processing on the gray code pattern image to obtain a binary image; 3) performing data analysis on the binary image and detecting the margin of each point to obtain a margin image; 4) performing data analysis on the margin image to track closed borders in the margin image and discard all non-closed borders in the margin image to obtain a closed border image; 5) performing data analysis on the closed border image, and calculating an area within every closed border to select positioning point cells; 6) performing rectangle matching on the positioning point cells to select one single image of the code pattern symbol; 7) grouping data points in the image of the code pattern symbol; 8) reconstructing a data point matrix; and 9) restoring code words.
In the decoding method of this invention, because a complete unit code pattern that at least includes four positioning points needs to be selected for rectangle matching, a relatively large code pattern area needs to be obtained. FIG. 1 shows minimum code pattern areas that need to be obtained in a worst case in the present invention and the prior art, where the outer larger rectangle is a minimum code pattern area that needs to be obtained in the prior art, that is, 6 times the area of a unit code pattern, and the smaller rectangle in a dashed box inside the larger rectangle is a minimum code pattern area that needs to be obtained in the present invention, that is, twice the area of a unit code pattern.